package com.jeomo.mem.starter.mapper;

import com.jeomo.base.starter.mapper.IBaseMapper;
import com.jeomo.mem.starter.entity.MemberDiscountRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 会员折扣规则
 * @author:Jackpot
 * @create 2020-09-09 14:51
 * @description:
 */
@Mapper
public interface MemberDiscountRuleMapper extends IBaseMapper<MemberDiscountRule> {

    /**
     * 获取折扣规则
     * @param level 会员等级
     * @param bsCode    业务编码 (如商品编码)
     * @return
     */
    @Select(" select m.rule from " +
            " member_discount_rule as m join member_discount_rule_list as d on m.id=d.discount_id  " +
            " where m.start_flag =1 and LOCATE(#{level},m.use_levels) >0 and d.bs_code=#{bsCode} ")
    String getMemberDiscountRule(String level, String bsCode);


//    @Update("update member_discount_rule set start_flag=#{status} where code=#{ruleCode}")
//    int updateRuleStatus(String ruleCode, int status);


}
